package com.ithuaxin.comprehensiveractice;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票原价");
        int price = sc.nextInt();
        System.out.println("请输入机票的月份");
        int month = sc.nextInt();
        System.out.println("请输入机票的舱型");
        String type = sc.next();
        if (month>=5 && month<=10){
            price = getNewPrice(price,type,0.9,0.85);
            System.out.println("机票的最新价格为："+price);

        }
        else if ((month>=11 && month<=12)||(month>=1 && month<=4)){
            price = getNewPrice(price,type,0.7,0.65);
            System.out.println("机票的最新价格为："+price);
        }


        else{
            System.out.println("您输入的月份错误");
        }

    }
    public static int getNewPrice(int price,String type,double v0,double v1){
        if (type.equals("头等舱")){
            price = (int)(price * v0);
        }else if (type.equals("经济舱")){
            price = (int)(price * v1);
        }else{
            System.out.println("您录入的数据是非法数据");
        }
        return price;
    }
}
